package com.jia.together.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jia.together.entity.CourseKnowledge;
import com.jia.together.entity.CourseKnowledge;
import com.jia.together.mapper.CourseKnowledgeMapper;
import com.jia.together.service.CourseKnowledgeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-20
 */
@Service
public class CourseKnowledgeServiceImpl extends ServiceImpl<CourseKnowledgeMapper, CourseKnowledge> implements CourseKnowledgeService {

    @Override
    public Map<String, Object> selectPageList(Long pageNum, Long pageSize) {

        Page<CourseKnowledge> page = new Page<>(pageNum, pageSize);
        QueryWrapper<CourseKnowledge> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("gmt_create");
        Page<CourseKnowledge> resourcePage = baseMapper.selectPage(page, wrapper);
        List<CourseKnowledge> records = resourcePage.getRecords();
        long total = resourcePage.getTotal();
        Map<String, Object> map = new HashMap<>();
        map.put("records", records);
        map.put("total", total);
        return map;

    }
}
